#include "stdafx.h"
#include "SlaveManager.h"

SlaveManager::SlaveManager()
{
}
SlaveManager::~SlaveManager()
{

}
Slave* SlaveManager::Add(SlaveId id)
{
	Slave* pSlave = manager<Slave,SlaveId>::Add(id);
	LOGGER_INFO("Add:%p,id:%d",pSlave,id);
	return pSlave;
}
bool SlaveManager::Remove(SlaveId id)
{
	if (id <= 0) return false;
	LOGGER_INFO("Remove,id:%d",id);
	return manager<Slave,SlaveId>::Remove(id);
}

Slave* SlaveManager::CreateFromSlaveInfo(SlaveInfo& info)
{
	Int32 nSlaveId = GenerateIdInt32();
	Slave* pSlave = Add(nSlaveId);
	if (pSlave == NULL)
	{
		LOGGER_ERROR("CreateFromSlaveInfo,pSlave == NULL,nSlaveId:%d",nSlaveId);
		return NULL;
	}
	pSlave->SetSlaveInfo(info);
	return pSlave;
}
